﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using IDAL;
using Model;

namespace DAL
{
    public class PCBAJointingCheck : BaseRepository_DT<PCBAJointingCheckInfo>, IPCBAJointingCheck
    {
        #region 静态变量部分
        private const string PARM_PCBAJOINTINGCHECK_PCBASN = "@PCBASN";
        private const string PARM_PCBAJOINTINGCHECK_RECORDTIME = "@RecordTime";
        private const string PARM_PCBAJOINTINGCHECK_USERID = "@UserID";
        private const string PARM_PCBAJOINTINGCHECK_FAILURENAME = "@FailureName";

        private const string PARM_PCBAJOINTINGCHECK_PRODUCTSN = "@ProductSN";
        #endregion

        #region 数据检索部分
        public IList<PCBAJointingCheckInfo> LoadEntities()
        {
            return null;
        }

        /// <summary>
        /// Get an individual category based on a provided id
        /// </summary>
        /// <param name="categoryId">Category id</param>
        /// <returns>Details about the Category</returns>
        public PCBAJointingCheckInfo LoadEntity<T1>(T1 pCBSN)
        {
            SqlParameter parm = GetParameter();
            //Bind the parameter
            parm.Value = pCBSN;
            return ExcuteSqlToGetEntity("PCBAJointingCheck_selectLastbySN", parm);
        }

        public IList<PCBAJointingCheckInfo> GetPCBAJointingChecksbySN(string pCBASN)
        {
            SqlParameter parm = GetParameter();
            parm.Value = pCBASN;
            return ExcuteSqlToGetEntities("PCBAJointingCheck_selectbySN", parm);
        }

        public IList<PCBAJointingCheckInfo> GetPCBAJointingChecksbyProductSN(string productSN)
        {
            SqlParameter parm = new SqlParameter(PARM_PCBAJOINTINGCHECK_PRODUCTSN, SqlDbType.NVarChar, 50);
            parm.Value = productSN;
            return ExcuteSqlToGetEntities("PCBAJointingCheck_selectbyProductSN", parm);
        }

        public IList<PCBAJointingCheckInfo> GetPCBAJointingChecksbyDT(DateTime starttime, DateTime stoptime)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = starttime;
            parms[1].Value = stoptime;
            return ExcuteSqlToGetEntities("PCBAJointingCheck_selectbyDT", parms);
        }
        #endregion

        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override PCBAJointingCheckInfo GetEntityRecord(SqlDataReader rdr)
        {
            PCBAJointingCheckInfo pro = new PCBAJointingCheckInfo(rdr.GetValue(0).ToString(), rdr.GetDateTime(1), rdr.GetValue(2).ToString(), rdr.GetValue(3).ToString());
            return pro;
        }

        public override PCBAJointingCheckInfo GetEntityRecord()
        {
            PCBAJointingCheckInfo pro = new PCBAJointingCheckInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "PCBAJointingCheck_Insert";
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return null;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_PCBAJOINTINGCHECK_PCBASN, SqlDbType.NVarChar, 50);
            return Parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_PCBAJOINTINGCHECK_PCBASN, SqlDbType.NVarChar, 50),
					new SqlParameter(PARM_PCBAJOINTINGCHECK_RECORDTIME, SqlDbType.DateTime, 8),
                    new SqlParameter(PARM_PCBAJOINTINGCHECK_USERID, SqlDbType.NVarChar, 10),
                    new SqlParameter(PARM_PCBAJOINTINGCHECK_FAILURENAME, SqlDbType.NVarChar, 50),
                };
            return parms;
        }

        public override void SetParameters(PCBAJointingCheckInfo jointingCheck, params SqlParameter[] Parms)
        {
            Parms[0].Value = jointingCheck.PCBASN;
            Parms[1].Value = jointingCheck.RecordTime;
            Parms[2].Value = jointingCheck.UserID;
            Parms[3].Value = jointingCheck.FailureName;
        }
        #endregion
    }
}
